package com.hean.activity;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;

import com.hean.entity.Resource;
import com.hean.util.NetUtil;
import com.hean.util.SAXParseService;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;

public class GetXmlFromNet extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		String path = "http://211.143.108.6/wap/ResCatService?act=pic&s=h";// 如果参数是中文需进行中文url编码
		try {
			String xml = NetUtil.getTextContent(path, "utf-8");
			FileOutputStream outputStream = new FileOutputStream(new File(
					Environment.getExternalStorageDirectory(), "test.xml"));
			outputStream.write(xml.getBytes());
			outputStream.close();
			System.out.println(xml);
			ByteArrayInputStream inputStream=new ByteArrayInputStream(xml.getBytes());
			Resource resource=SAXParseService.parseXml(inputStream);
			System.out.println(resource);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
